from django.shortcuts import render,redirect,HttpResponseRedirect
from urllib import request
from Big_Data_View import models

def login_auth(request):
    if request.method=='POST':
        username = request.POST.get('username')
        password = request.POST.get('password')
        message = "所有字段都必须填写"
        if username !="" and password !="":
            username = username.strip()
            try:
                user=models.User_Big_Data_View.objects.get(username=username)
                if user.password == password:
                    print(password)
                    return HttpResponseRedirect('/big_data_view/')
                else:
                    return render(request,'login.html',{'error':"密码不正确"})
            except:
                return render(request,'login.html',{'error':"账号不存在"})
        else:
            return render(request,'login.html',{'error':"账号或者密码为空"})
    else:
        return render(request,'login.html')
